package Enums;

public enum MovementState {
	/** 0 */
	BREWING(0),
	/** 5 */
	FERMENTING(5),
	/** 10 */
	LAGERING(10),
	/** 15 */
	CONDITIONING(15),
	/** 16 */
	BARREL_FOR_PACKAGING(16),
	/** 20 */
	KEGGED(20),
	/** 21 */
	BOTTLED(21),
	/** 25 */
	BARREL_CONDITIONING(25),
	/** 22 */
	FIRKIN(22);

	private int state;

	MovementState(final int state) {
		this.state = state;
	}

	public int getState() {
		return state;
	}

	public static MovementState getState(final String state) {
		return getState(Integer.parseInt(state));
	}

	public static MovementState getState(final int state) {

		switch (state) {
		case 0:
			return BREWING;
		case 5:
			return FERMENTING;
		case 10:
			return LAGERING;
		case 15:
			return CONDITIONING;
		case 16:
			return BARREL_FOR_PACKAGING;
		case 20:
			return KEGGED;
		case 21:
			return BOTTLED;
		case 25:
			return BARREL_CONDITIONING;
		case 22:
			return FIRKIN;
		default:
			throw new EnumConstantNotPresentException(MovementState.class,
					String.valueOf(state));
		}
	}

	public static int getStateID(final String state) {

		if (state.equals("BREWING")) {
			return 0;
		}
		if (state.equals("FERMENTING")) {
			return 5;
		}
		if (state.equals("LAGERING")) {
			return 10;
		}
		if (state.equals("CONDITIONING")) {
			return 15;
		}
		if (state.equals("BARREL_FOR_PACKAGING")) {
			return 16;
		}
		if (state.equals("KEGGED")) {
			return 20;
		}
		if (state.equals("BOTTLED")) {
			return 21;
		}
		if (state.equals("BARREL_CONDITIONING")) {
			return 25;
		}
		if (state.equals("FIRKIN")) {
			return 22;
		}
		return 0;
	}

	public static String getStateDescription(final int state) {

		switch (state) {
		case 0:
			return "Brewing";
		case 5:
			return "Begin Primary Fermentation";
		case 10:
			return "Move From Primary to Lagering";
		case 15:
			return "Move From Lagering to Conditioning";
		case 16:
			return "Move From Barrels into Conditioning";
		case 20:
			return "Move to Kegs";
		case 21:
			return "Move to Bottles";
		case 25:
			return "Move to Barrels";
		case 22:
			return "Move to Firkin";
		default:
			throw new EnumConstantNotPresentException(MovementState.class,
					String.valueOf(state));
		}
	}

	public static int getStateFromDescription(final String state) {

		if (state.equals("Brewing")) {
			return 0;
		}
		if (state.equals("Begin Primary Fermentation")) {
			return 5;
		}
		if (state.equals("Move From Primary to Lagering")) {
			return 10;
		}
		if (state.equals("Move From Lagering to Conditioning")) {
			return 15;
		}
		if (state.equals("Move From Barrels into Conditioning")) {
			return 16;
		}
		if (state.equals("Move to Kegs")) {
			return 20;
		}
		if (state.equals("Move to Bottles")) {
			return 21;
		}
		if (state.equals("Move to Barrels")) {
			return 25;
		}
		if (state.equals("Move to Firkin")) {
			return 22;
		}
		return 0;
	}
}
